#ifndef _RELAYMOTOR_H_
#define _RELAYMOTOR_H_
#include "stdint.h"
#include "stm32f4xx.h"

/****************RELAY*******************/
#define RELAY1_PORT			GPIOC
#define RELAY1_PIN			GPIO_Pin_15
#define RELAY2_PORT			GPIOC
#define RELAY2_PIN			GPIO_Pin_14
#define RELAY3_PORT			GPIOC
#define RELAY3_PIN			GPIO_Pin_13
#define RELAY4_PORT			GPIOE
#define RELAY4_PIN		    GPIO_Pin_6

#define  RELAY1_ON()	  	GPIO_SetBits(RELAY1_PORT,RELAY1_PIN)
#define	 RELAY1_OFF()	    GPIO_ResetBits(RELAY1_PORT,RELAY1_PIN)
#define	 RELAY1_TOGGLE()	GPIO_ToggleBits(RELAY1_PORT,RELAY1_PIN)

#define  RELAY2_ON()	  	GPIO_SetBits(RELAY2_PORT,RELAY2_PIN)
#define	 RELAY2_OFF()		GPIO_ResetBits(RELAY2_PORT,RELAY2_PIN)
#define	 RELAY2_TOGGLE()	GPIO_ToggleBits(RELAY2_PORT,RELAY2_PIN)

#define  RELAY3_ON()	  	GPIO_SetBits(RELAY3_PORT,RELAY3_PIN)
#define	 RELAY3_OFF()		GPIO_ResetBits(RELAY3_PORT,RELAY3_PIN)
#define	 RELAY3_TOGGLE()	GPIO_ToggleBits(RELAY3_PORT,RELAY3_PIN)

#define  RELAY4_ON()	  	GPIO_SetBits(RELAY4_PORT,RELAY4_PIN)
#define	 RELAY4_OFF()		GPIO_ResetBits(RELAY4_PORT,RELAY4_PIN)
#define	 RELAY4_TOGGLE()	GPIO_ToggleBits(RELAY4_PORT,RELAY4_PIN)

/****************APPLICATION*******************/
#define NEST_WINDOW_RELAY1_ON()       RELAY1_ON()
#define NEST_WINDOW_RELAY1_OFF()      RELAY1_OFF()
#define NEST_WINDOW_RELAY1_TOGGLE()   RELAY1_TOGGLE()

#define NEST_WINDOW_RELAY2_ON()       RELAY2_ON()
#define NEST_WINDOW_RELAY2_OFF()      RELAY2_OFF()
#define NEST_WINDOW_RELAY2_TOGGLE()   RELAY2_TOGGLE()

#define NEST_BLAKE_RELAY1_ON()       RELAY3_ON()
#define NEST_BLAKE_RELAY1_OFF()      RELAY3_OFF()
#define NEST_BLAKE_RELAY1_TOGGLE()   RELAY3_TOGGLE()

#define NEST_BLAKE_RELAY2_ON()       RELAY4_ON()
#define NEST_BLAKE_RELAY2_OFF()      RELAY4_OFF()
#define NEST_BLAKE_RELAY2_TOGGLE()   RELAY4_TOGGLE()

typedef enum{
	_RELAYNONE = 0,
	_RELAYONE,
	_RELAYTWO,
	_RELAYTHREE,
	_RELAYFOUR,
}E_RELAY_LIST;

typedef enum{
	RELAY_OFF = 0,
	RELAY_ON,
}E_RELAY_ONOFF_LIST;

typedef enum{
	RELAY_NEGATIVE = 0,
	RELAY_POSITIVE,
}E_RELAY_DIR_LIST;

void Relay_Gpio_Init(void);
void Relay_Process(uint8_t num,uint8_t onoff,uint8_t dir);
void Set_Relay(uint8_t num,uint8_t onoff,uint8_t dir);
void Relay_Ctrl(void);
#endif

